<%@ page contentType="text/html;charset=UTF-8" %>

<html>
<head>
	<title>被举报的信息查询</title>
	 <%@ include file="/common/meta.jsp" %>
	<%@ include file="/common/import.jsp" %>
	<script type="text/javascript">
	
		$(function(){
			$('#sortList').datagrid({
				title:'被举报的信息列表',
				iconCls:'icon-ok',
				url:'${ctx}/info/admin/topage!data.action?sortCode=s_jubao&f='+new Date().getTime(),
				striped: true,
				collapsible:false,				
				fitColumns: true,
				pagination:true,
				singleSelect:true,
				rownumbers:true,
				remoteSort: false,
				pageList:[10,15,20,30],
				idField:'sortId',
				columns:[[
					{field:'infoTitle',title:'信息标题',width:170,
						formatter:function(val){
							return getSubInfo(val,15);
						}
					},
					{field:'infoType',title:'信息类型',width:45},
					{field:'infoCreateUser',title:'信息发布人',width:100},					
					{field:'remark',title:'举报理由',width:110,
						formatter:function(val,rows){
							return getSubInfo(val,rows,6);
						}},
					{field:'createTime',title:'举报时间',width:100},
					{field:'createUser',title:'举报人',width:100},
					{field:'status',title:'状态',width:80,
						formatter:function(value){
							if(value=="1") return "待运营商核实";
							if(value=="2") return "发布者处理中";
							if(value=="3") return "已被强制删除";
							if(value=="4") return "有效信息";
						}
					},
					{field:'infoId',title:'操作',width:80,
						formatter:function(value,rowData){
							var str = "";
							if(rowData.status=='1'){
								 str += "<a href='javascript:void(0);' onclick=\"sendMsgInfo('"+rowData.objId+"','"+rowData.infoId+"','"+rowData.infoTitle+"','"+rowData.infoType+"','"+rowData.remark+"','"+rowData.createUser+"','"+rowData.infoCreateUser+"','"+rowData.createTime+"')\">通知处理</a>  &nbsp;";
								 str += "<a href='javascript:void(0);' onclick=\"upJubaoStatus('"+rowData.infoId+"','"+rowData.infoTitle+"','4')\">没问题</a> ";
							}
							if(rowData.status=='1' || rowData.status=="2"){
								if(str!="")str+="<br/>";
								str+="<a href='javascript:void(0);' onclick=\"qzDelInfo('"+rowData.srcSortCode+"','"+rowData.objId+"','"+rowData.infoId+"','"+rowData.infoTitle+"')\">强制处理</a>";
							}
							return str;
						}
					}
				]]
			});
		});
			
		// 刷新列表
		function reload(){
			$('#sortList').datagrid('reload');
		}
	
		//修改举报信息状态（控制是否处理）
		function upJubaoStatus(jubaoId,jubaoTitle,st){
			//alert(jubaoId+"-"+jubaoTitle+"-"+st);
			if(st=='4' && !confirm("您确认要处理吗？"))return;
			var urlupjubao = "${ctx}/info/admin/upStatus.action?sortCode=s_jubao&infoId="+jubaoId+"&status="+st;
			$.ajax({
				   type:'get',
				   url:urlupjubao,
				   dataType:'json',
				   success: function(myData){
					   alert(myData.msg);
					   reload();
				  }
			});	
		}
		//给发布者用户中心发送消息记录通知，告知其处理。，并且标记举报信息已处理
		function sendMsgInfo(objId,jubaoId,jubaoTitle,infoType,remark,jubaouser,infosrcuser,createTime){
			//删除被举报的信息所处表单的数据
			if(jubaoTitle && confirm("您确认给此【"+jubaoTitle+"】信息的发布者，发送站内信息通知吗？")){
				var urlSendMsg = "${ctx}/info/admin/addMessge.action";
				$("#noticeTitle").val("您的【"+jubaoTitle+"】信息已被举报");
				$("#userEname").val(infosrcuser);
				var notHtml = "信息类型："+infoType;
				notHtml+="<br/>举报时间："+createTime;
				notHtml+="<br/>举报理由："+remark;
				notHtml+="<br/><font color=red>平台意见：请尽快停止发布，进行整改！</font>";
				$("#noticeContent").val(notHtml);
				$.ajax({
					   type:'POST',url:urlSendMsg,dataType:'json',data: $("#msgForm").serialize(),
					   success: function(myData){
						 //修改举报记录信息状态（已处理）
						 if("T"==myData.flag){
							 upJubaoStatus(jubaoId,jubaoTitle,"2");
						 }
					  }
				});	
			}
		}
		//强制删除发布信息，并且标记举报信息已处理
		function qzDelInfo(srcSortCode,objId,jubaoId,jubaoTitle){
			//删除被举报的信息所处表单的数据
			if(srcSortCode && objId && jubaoId && confirm("您确认要强制删除被举报的信息【"+jubaoTitle+"】吗？\n删除后不可恢复！")){
				var urldel = "${ctx}/info/admin/delInfo.action?sortCode="+srcSortCode+"&infoId="+objId;
				$.ajax({
					   type:'get',url:urldel,dataType:'json',
					   success: function(myData){
						   alert(myData.msg);
						 //修改举报记录信息状态（已处理）
						   upJubaoStatus(jubaoId,jubaoTitle,"3");
					  }
				});	
			}
		}
		
		function getSubInfo(str,rows,len){
			var re = "";
			if(str && str.length>len){
				re = str.substring(0,len-1)+"... ";
			}else{
				re = str;
			}
			return re+"<a href='javascript:void(0);' onclick=\"oWin('"+str+"','"+rows.contactName+"','"+rows.contactPhone+"','"+rows.contactEmail+"','"+rows.createTime+"')\" >更多</a>";
		}
		function oWin(msg,contactName,contactPhone,contactEmail,createTime){
			var hst = "<b>举报内容：</b>"+msg;
			hst+="<br/><b>举报人姓名：</b>"+contactName;
			hst+="<br/><b>举报人电话：</b>"+contactPhone;
			hst+="<br/><b>举报人邮箱：</b>"+contactEmail;
			hst+="<br/><b>举报的时间：</b>"+createTime;
			$("#div_msg").html(hst);
			//rows.contactName+"','"+rows.contactPhone+"','"+rows.contactEmail+"','"+rows.createTime
			$("#infoDetailWin").window('open');
			
		}
		function cWin(){
			$("#infoDetailWin").window('close');
			$("#div_msg").html("");
		}
	</script>
</head>
<body>
	<!-- 应用列表 -->
	<table id="sortList"></table>
	
	<div id="infoDetailWin"  class="easyui-window" title="查看详情" 
	style="padding:2px;width:500px;height:380px;"
	iconCls="icon-search" closed="true" maximizable="false" minimizable="false" collapsible="false">
		<div id="div_msg" style="padding: 10px;line-height:30px;"></div>
    </div>
    
    <form method="post" id="msgForm" name="msgForm">
		<input name="noticeTitle" type="hidden" id="noticeTitle"/>
		<input name="userEname" type="hidden" id="userEname"/>
		<input name="noticeContent" type="hidden" id="noticeContent"/>
    </form>
</body>
</html>